<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class InitGroupPrice extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('user_group_price', function (Blueprint $table) {
            $table->comment = '人群价表';
            
            $table->increments('id');
            $table->uuid('uuid')->index() ;

            $table->string('title', 30)->comment('标题，显示在商品详情页中');

            $table->integer('group_id')->index()->comment('用户分组id');
            $table->string('target_type', 20)->index()->comment('绑定类型');
            $table->integer('target_id')->index()->comment('商品id或者其它盲盒id');

            $table->integer('discount_type')->default(1)->comment('折扣方式、1为固定价、2为打折价');

            $table->integer('discount_ratio')->nullable()->comment('打折 75表示75折');

            $table->integer('score_price')->nullable()->comment('积分价');
            $table->integer('money_price')->nullable()->comment('人民币价');


            $table->integer('stock')->nullable()->comment('库存');
            $table->integer('sales')->default(0)->comment('销量');

            $table->integer('list_weight')->default(99)->comment('权重');
            $table->boolean('status')->default(1)->index()->comment('1为上架中,  0为下架中');

            $table->softDeletes();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::disableForeignKeyConstraints();
        Schema::dropIfExists('user_group_price');
    }
}
